package com.uva.dbcs.web.beans.gestionDeVehiculos.utils;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.uva.dbcs.gestionDeVehiculos.dominio.Vehiculo;

public class VehiculoDataModel extends ListDataModel<Vehiculo> implements
		SelectableDataModel<Vehiculo>, Serializable {


	private static final long serialVersionUID = 1L;

	public VehiculoDataModel() {
	}
	
	public VehiculoDataModel(List<Vehiculo> data) {
		
		super(data);
	}
	
	
	@SuppressWarnings("unchecked")
	@Override
	public Vehiculo getRowData(String rowKey) {
		List<Vehiculo> cars = (List<Vehiculo>) getWrappedData();
		for(Vehiculo car : cars) {
			if(car.getIdvehiculo()==Integer.parseInt(rowKey))
				return car;
		}
	

		return null;
	}

	@Override
	public Object getRowKey(Vehiculo car) {
		
		return car.getIdvehiculo();
	}

}
